package com.shujia.wyh.regulardemo;

import java.util.Arrays;

/*
    元字符（边界分类）
    ^:以xxx开头
    $:以xxx结尾
    \b:单词边界
    \B:非单词边界
 */
public class RegularDemo6 {
    public static void main(String[] args) {
        // www.baidu.com    www.shujia.com   www.xiaohu123.com  www.liutianbaoshishuaige.com.cn
        String line = "www.baidu.com";
//        String regex1 = "[^w]";  //  [^w]  匹配除了w字符以外的字符

        String regex1 = "^w";  // 匹配以w开头的字符
        System.out.println(line.replaceAll(regex1, "_"));

        String regex2 = "com$"; //判断以xxx结尾
        System.out.println(line.replaceAll(regex2,"_"));
        System.out.println("------------------------------------------------");
        String s2 = "hello woreld da a vw java h";
//        String[] split = s2.split("\b");

//        System.out.println(Arrays.toString(split));
        System.out.println(s2.replaceAll("\\B","_"));
    }
}
